<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
	<meta charset="utf-8">
    <title> Add dv_payments-Payment Page</title>
<?php echo link_tag(my_url().'skin.css'); ?>
<?php echo link_tag(my_url().'tcal.css'); ?>
<script type="text/javascript" src="<?php echo my_url(); ?>js/1.js"></script>
<script type="text/javascript" src="<?php echo my_url(); ?>tcal.js"></script> 
<script type="text/javascript" src="<?php echo my_url(); ?>js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<?php echo my_url(); ?>js/jquery-1.6.4.min.js"></script> 
<script type="text/javascript" src="../js/1.js"></script>
<script src="<?php echo my_url(); ?>js/AC_RunActiveContent.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var BaseURL='<?php echo base_url(); ?>'; 
function redirect(location){
	window.location.href= location;
}
$(document).ready(function(){
 	$("#load_no").change(function(){				
		var _url= BaseURL + "dv_payments/p_getinfo?load_no=" + this.value;
		$.post(_url,"",callbackdisplay);
	});
  	 $('.bal').keyup(function() {   
	   	  var ca=$('input[name=contract_amount]').val();  
		  var ad=$('input[name=advance]').val(); 
	   	  var lp=$('input[name=last_payment]').val(); 		  
		  var ad_val=0.00;
		  var ca_val=0.00;
		  var lp_val=0.00;		  
		  if(!isNaN(ca) && ca!=""){
		   ca_val=parseFloat(ca);
		  }
		  if(!isNaN(ad) && ad!=""){
			ad_val=parseFloat(ad);
		  }

		  if(!isNaN(lp) && lp!=""){
			lp_val=parseFloat(lp);
		  }			
		  var bal = ca_val -(ad_val + lp_val);	
		  $('input[name=balance]').val(bal ); 		
    });

});


function callbackdisplay(data,status){
		if(status=="success"){
			$("#driver_co").val(data.dv_company_name);
			$("#contract_amount").val(data.dv_rate);		
		}
}

</script>

<link rel="stylesheet" type="text/css" href="tcal.css" />
<link rel="stylesheet" href="../skin.css" type="text/css" media="screen" /><meta name="author" content="Jaypee Mahilum" />
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<link href="skin.css" rel="stylesheet" type="text/css" />
</head>
<?php
//echo $_SESSION['administrator_log']."============";
if(!isset($_SESSION['administrator_log']))
{
		echo"Log in first to access this page<html><title>WARNING</title><body><br><a href='".base_url()."administrator' />click here to log in.</a></body></html>";
}
else
{
?>
<body >
	<div class="BodyCover">
 		<div class="ParentContent">
	        <?php require("owner_menu.php"); ?>

			<div class="MenuTab">

    			<div class="MenuBelow"><img src="<?php echo my_url();?>images/below-menu.gif"></div>        

             </div>



			<br /><br />	

			<div class="module-index1">

		  		<div align="right"><a href="<?php echo base_url()?>admin/logout" style="color:#FF0000;">logout</a></div><br/>

  	                <p class=""><?php if (isset($recordflag)) {echo $recordflag;}?><p>

			   <h1>Add Driver/Vendor </h1>

                 <form action="<?php echo base_url()?>dv_payments/p_add_dv_payments" method="post" name="sum" class="bal" >
   <?php if(isset($data_exists)){ echo "<p><label style='color:#F00;'>$data_exist</label></p>";} ?>
                    <label>Load No.:</label><?php  echo select_list("loads","loads_id","load_no","loads_id","","name='load_no' id='load_no' "); ?> <br />	

                    <label>Driver Company:</label> <input size="25" name="driver_co" id="driver_co" value=""  /> <br />

                    <label>Nick Name:</label> <input size="25"  name="n_name" id="n_name" />  <br />

                    <label>Contract Amount $:</label> <input size="5"  class="bal" name="contract_amount" id="contract_amount" /> <br />

                    <label>Advance $:</label> <input  class="bal" name="advance" id="advance" /> <br />

                    <label>Type:</label> <input size="15" name="type"  /><br />

                    <label>Date:</label> <input size="10" type="text" name="date" class="tcal" value=""/> <br />

                    <label>Reference:</label> <input size="5" name="reference"/> <br />

                    <label>Reference Name:</label> <input size="15" name="ref_name"/> <br />

					<label>Last Payment $:</label> <input id="last_payment" class="bal" size="5" name="last_payment"/> <br />

                    <label>Balance $:</label> <input size="5" class="balance" id="balance" name="balance" type="text"  value="0" /> <br />  <br /> 



                 	<input type="submit"  value="Save" name="cmdsave" id="cmdsave">                               

					<input type="button"  value="Cancel" onclick="redirect(BaseURL+'dv_payments')" name="cmdcancel">

				</form>

    		<br>



            <div class="BodyContent">

            </div>	

			    		

		    <div class="Footer1">	

                <div class="Footer">Copyright &copy; 2011. All Rights Reserved <br><br>

                 <a href="http://webmartis.com"> <img src="<?php echo my_url();?>images/wmlink.png"></a>

                 

                </div>                

            </div> <!---end of Footer1 ---->        

            

		</div><!---end of ParentContent ---->

    </div> <!---end of BodyCover ---->

</body>

<?php } ?>

</html>



